import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:oral_cloud/config/constant.dart';
import 'package:oral_cloud/config/resource_mananger.dart';
import 'package:oral_cloud/config/router_manger.dart';
import 'package:oral_cloud/model/patient.dart';

import 'global_widget.dart';
import 'image.dart';

class PatientGridItemWidget extends StatelessWidget {
  final double vSpace = ScreenUtil.getInstance().setHeight(16);
  final Patient patient;
  final int index;
  PatientGridItemWidget(this.patient, {this.index});
  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: () {
        print('onTap===>patient=$patient');
        Navigator.of(context).pushNamed(RouteName.patient_details,arguments: patient);
      },
      child: Container(
        padding: EdgeInsets.only(
          left: ScreenUtil.getInstance().setWidth(30),
          top: ScreenUtil.getInstance().setHeight(54),
          bottom: ScreenUtil.getInstance().setHeight(48),
          right: ScreenUtil.getInstance().setWidth(30),
        ),
        child: Row(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Stack(
              alignment: Alignment.bottomRight,
              children: [
                ClipOval(
                  child: WrapperImage(
                    imageType: ImageType.normal,
                    url: patient.avatar,
                    placeholder: patient.sex==1?'male_default.png':'female_default.png',
                    height: ScreenUtil.getInstance().setWidth(120),
                    width: ScreenUtil.getInstance().setWidth(120),
                  ),
                ),
                Image.asset(ImageHelper.wrapAssets(patient.sex==1?'male.png':'female.png'),
                  width: ScreenUtil.getInstance().setWidth(35),
                  height: ScreenUtil.getInstance().setWidth(35),
                )
              ],
            ),
            SizedBox(width: ScreenUtil.getInstance().setWidth(30),),
            Expanded(
              child:Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Text(
                    '姓名:${patient.username}',
                    style: TextStyle(
                      color: Color(MYColors.textHighlightColor),
                      fontSize: FontSize.fontSizeXL,
                    ),
                  ),
                  SizedBox(height: vSpace,),
                  NormalText('患者编号:${patient.patientNo}'),
                  SizedBox(height: vSpace,),
                  NormalText('出生日期:${patient.birthDate}'),
                  SizedBox(height: vSpace,),
                  NormalText('录入日期:${patient.recordDate}'),
                  SizedBox(height: ScreenUtil.getInstance().setHeight(38),),
                  ViewDetailsWidget(),
                ],
              ),
            ),

          ],
        ),
        decoration:  BoxDecoration(
          borderRadius:BorderRadius.circular(4),
          boxShadow: <BoxShadow>[
             BoxShadow(
               color: Colors.white,
            ),
          ],
        ),
      ),
    );
  }


}

class ViewDetailsWidget extends StatelessWidget {

  ViewDetailsWidget();

  @override
  Widget build(BuildContext context) {
    return
      Container(
        alignment: Alignment.center,
        width: ScreenUtil.getInstance().setWidth(142),
        height: ScreenUtil.getInstance().setHeight(54),
        decoration: new BoxDecoration(
            color:Color(0xffF2FBF8) ,
            borderRadius: BorderRadius.circular(ScreenUtil.getInstance().setWidth(30)),
            border: new Border.all(
                color: Color(MYColors.borderFocusColor),
                width: 0.5)),
        child: Text(
    '查看',
    style: TextStyle(
    fontSize: FontSize.fontSizeL,
    color: Color(MYColors.borderFocusColor))));
  }
}


